/**
 * Created by Administrator on 2017/4/13 0013.
 */
var Page0={
    create:function () {
        var page={};

        page.ui=new PIXI.DisplayObjectContainer();

        page.ui.pivot.x=740/2;
        page.ui.pivot.y=1136/2;
        page.ui.x=740/2;
        page.ui.y=1136/2;

        var sp_bg=Easy.CreateSprite('assets/images/p0_bg.png',0,0,0,0,1);
        page.ui.addChild(sp_bg);

        // var i1=Easy.CreateSprite('assets/images/p0_i1.png',157,143,0.0,0.0,1);
        // page.ui.addChild(i1);
        // var i0=Easy.CreateSprite('assets/images/p0_i0.png',155,143,0.0,0.0,1);
        // page.ui.addChild(i0);
        // i0.on('pointerdown',downHandler);
        // var man1=Easy.CreateSprite('assets/images/man1.png',368,532,0.5,0.5,1);
        // page.ui.addChild(man1);
        // var man0=Easy.CreateSprite('assets/images/man0.png',368,533,0.5,0.5,1);
        // page.ui.addChild(man0);
        var arr_texture=[];
        for(var i=0;i<101;i++)
        {
            if(i<10)
            {
                var texture = resource['assets/images/P01/P01.00'+i.toString()+'.png'].texture;
            }
            else if(i<100)
            {
                var texture = resource['assets/images/P01/P01.0'+i.toString()+'.png'].texture;
            }
            else
            {
                var texture = resource['assets/images/P01/P01.'+i.toString()+'.png'].texture;
            }
            arr_texture.push(texture);
        }
        var mc=new PIXI.extras.AnimatedSprite(arr_texture);
        mc.animationSpeed=0.5;
        mc.loop=false;
        page.ui.addChild(mc);


        page.ui.on('pointerdown',downHandler);

        var t0=Easy.CreateSprite('assets/images/p0_t0.png',370,100,0.5,0.5,0);
        page.ui.addChild(t0);
        var t1=Easy.CreateSprite('assets/images/p0_t1.png',370,183,0.5,0.5,0);
        page.ui.addChild(t1);
        var t2=Easy.CreateSprite('assets/images/p0_t2.png',33,546,0.5,0.5,0);
        page.ui.addChild(t2);
        var t3=Easy.CreateSprite('assets/images/p0_t3.png',706,571,0.5,0.5,0);
        page.ui.addChild(t3);
        var t4=Easy.CreateSprite('assets/images/p0_t4.png',358,492,0.5,0.5,0);
        page.ui.addChild(t4);
        var t5=Easy.CreateSprite('assets/images/p0_t5.png',372,1048,0.5,0.5,0);
        page.ui.addChild(t5);
        
        page.In=function () {
            // TweenMax.to(t0,1,{})
            t4.y=522+50;
            TweenMax.to(t4,1,{alpha:1,y:522,onComplete:function () {
                page.ui.interactive=true;
            }});
        }
        function downHandler(e) {
            page.ui.interactive=false;
            mc.gotoAndPlay(1);
            // if(ripples.length<5)
            // {
            //     var ripple=new Ripple(-i0.x+e.data.global.x/(innerWidth/pixiStageW),-i0.y+ e.data.global.y/(innerHeight/pixiStageH),i0);
            //     ripples.push(ripple);
            //
            //     i0.filters = ripples.map(function (element) {
            //         return element.filter;
            //     });
            // }
            // TweenMax.to(i0,3,{delay:1,alpha:0,ease:Linear.easeNone});
            t0.x=370+50;
            t1.x=370+50;
            t0.alpha=t1.alpha=0;
            TweenMax.to(t0,1,{delay:0.2*0,x:370,alpha:1,ease:Cubic.easeInOut});
            TweenMax.to(t1,1,{delay:0.2*1,x:370,alpha:1,ease:Cubic.easeInOut});

            t2.x=22-50;
            t2.alpha=0;
            TweenMax.to(t2,1,{delay:0.2*3,x:22+65,alpha:1,ease:Cubic.easeInOut});
            t3.x=714+50;
            t3.alpha=0;
            TweenMax.to(t3,1,{delay:0.2*3,x:714-65,alpha:1,ease:Cubic.easeInOut});
            t5.y=1026+50;
            t5.alpha=0;
            TweenMax.to(t5,1,{delay:0.2*4,y:1026,alpha:1,ease:Cubic.easeInOut});

            setTimeout(function()
            {
                TweenMax.to(page.ui.scale,2,{x:4,y:4,ease:Cubic.easeIn});
                TweenMax.to(page.ui,1,{delay:1,alpha:0,ease:Cubic.easeIn});
            },3000);
            setTimeout(function()
            {
                document.dispatchEvent(new CustomEvent('Game_PageIn',{detail:'p1'}));
            },4500);

        }

        return page;
    }
}